<template>
	<view class="setting-container" :style="{height: `${windowHeight}px`}">
		<view class="menu-list">
			<view class="list-cell list-cell-arrow" @click="handleToPwd">
				<view class="menu-item-box">
					<view class="iconfont icon-password menu-icon"></view>
					<view>修改密码</view>
				</view>
			</view>
			<view class="list-cell list-cell-arrow" @click="handleToUpgrade">
				<view class="menu-item-box">
					<view class="iconfont icon-refresh menu-icon"></view>
					<view>检查更新</view>
				</view>
			</view>
			<view class="list-cell list-cell-arrow" @click="handleCleanTmp">
				<view class="menu-item-box">
					<view class="iconfont icon-clean menu-icon"></view>
					<view>清理缓存</view>
				</view>
			</view>
		</view>
		<view class="cu-list menu">
			<view class="cu-item item-box">
				<view class="content text-center" @click="handleLogout">
					<text class="text-black">退出登录</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		useUserStore
	} from '@/store/user'
	import {
		getCurrentInstance,
		ref
	} from "vue";
	const {$tab, $modal} = getCurrentInstance().appContext.config.globalProperties;
	const userStore = useUserStore();
	const windowHeight = ref(uni.getSystemInfoSync().windowHeight)

	function handleToPwd() {
		$tab.navigateTo("/pages/mine/pwd/index");
	}

	function handleToUpgrade() {
		$modal.showToast('模块建设中~')
	}

	function handleCleanTmp() {
		$modal.showToast('模块建设中~')
	}

	function handleLogout() {
		$modal.confirm('确认注销么？').then(() => {
			userStore.LogOut().then(() => {
				$tab.reLaunch('/pages/index');
			})
		})
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #f8f8f8;
	}

	.item-box {
		background-color: #FFFFFF;
		margin: 30rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		padding: 10rpx;
		border-radius: 8rpx;
		color: #303133;
		font-size: 32rpx;
	}
</style>